package com.atguigu.tingshu.account.rpc;

import com.atguigu.tingshu.account.service.RechargeInfoService;
import com.atguigu.tingshu.account.service.UserAccountService;
import com.atguigu.tingshu.common.result.Result;
import com.atguigu.tingshu.model.account.RechargeInfo;
import com.atguigu.tingshu.vo.account.AccountLockResultVo;
import com.atguigu.tingshu.vo.account.AccountLockVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Author:huzhongkui
 * Date: 2025-03-28 星期五 11:23:53
 * Description:
 */

@RestController
@RequestMapping("/api/inner/accountinfo")
public class UserAccountRpcController {

    @Autowired
    private UserAccountService userAccountService;

    @Autowired
    private RechargeInfoService rechargeInfoService;


    @PostMapping("/checkAndLockAmount")
    Result<AccountLockResultVo> checkAndLockAmount(@RequestBody AccountLockVo accountLockVo) {

        return userAccountService.checkAndLockAmount(accountLockVo);
    }

    @PostMapping("/getRechargeInfoByOrderNo/{orderNo}/{userId}")
    Result<RechargeInfo> getRechargeInfoByOrderNo(@PathVariable(value = "orderNo") String orderNo, @PathVariable(value = "userId") Long userId) {

        RechargeInfo rechargeInfo = userAccountService.getRechargeInfoByOrderNo(orderNo, userId);
        return Result.ok(rechargeInfo);

    }
}
